package com.bdqn.gulimall.order.controller;

import com.bdqn.gulimall.order.entity.OrderReturnApplyEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

@RestController
public class RabbitmqController {

    @Resource
    RabbitTemplate rabbitTemplate;

    @GetMapping("/send")
    public String goMesg(){
        OrderReturnApplyEntity returnApplyEntity = new OrderReturnApplyEntity();
        returnApplyEntity.setId(1L);
        returnApplyEntity.setCreateTime(new Date());
        returnApplyEntity.setProductName("好好");
        rabbitTemplate.convertAndSend("bdqn-java-exchange","bdqn.java",returnApplyEntity);
        System.out.println("发送成功");
        return "ok";
    }

}
